package com.experienceBaby.Cashbook.activity;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;

import com.experienceBaby.Cashbook.databinding.ActivityAddBinding;
import com.experienceBaby.Cashbook.databinding.ActivityEditorItemBinding;
import com.experienceBaby.Cashbook.fragment.AddItemFragment;
import com.experienceBaby.Cashbook.greendao.DbController;
import com.xuexiang.xui.XUI;

import java.util.ArrayList;

public class EditorItemActivity extends AppCompatActivity {

    ActivityEditorItemBinding mBinding;

    @Override
    protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
        XUI.init(getApplication());
        XUI.initTheme(this);
        super.onCreate(savedInstanceState);
        // View Binding
        mBinding = ActivityEditorItemBinding.inflate(getLayoutInflater());
        View rootView = mBinding.getRoot();
        setContentView(rootView);
        initView();
    }

    private void initView() {
        DbController dbController = new DbController(this);
        ArrayList<Fragment> fragmentlist = new ArrayList<>();
        fragmentlist.add(new AddItemFragment(dbController, false));
        fragmentlist.add(new AddItemFragment(dbController, true));

        mBinding.tabs.setViewPager(mBinding.viewpager, new String[]{"支出", "收入"}, this, fragmentlist);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mBinding = null;
    }
}
